﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace WellDone
{
    public sealed partial class CreditReaderDialog : Page
    {
        public event EventHandler CloseRequested;
        public CreditReaderDialog()
        {
            this.InitializeComponent();
        }
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            // Set the "Canceled" flag
            //bCanceled = true;
            // Close the dialog
            if (this.CloseRequested != null)
            {
                this.CloseRequested(this, EventArgs.Empty);
            }
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            // Close the dialog
            if (this.CloseRequested != null)
            {
                this.CloseRequested(this, EventArgs.Empty);
            }
        }

        private void tbMagStripeData_Loaded(object sender, RoutedEventArgs e)
        {
            if (tbMagStripeData != null)
                tbMagStripeData.Focus(FocusState.Programmatic);
        }

        private void tbMagStripeData_TextChanged(object sender, TextChangedEventArgs e)
        {
            string strText=tbMagStripeData.Text;
            if (strText.EndsWith("1000"))
            {
                System.Diagnostics.Debug.WriteLine(strText);
                btnOK.IsEnabled = true;
                btnCancel.IsEnabled = true;
            }
            else btnCancel.IsEnabled = false;
        }
    }
}
